import request from "@/utils/request";

// 注册
export const reqRegUser=(username, password, sex,age, idCard, phone, confirmPassword)=>{
  console.log(username,
    password,
    sex,
    parseInt(age),
    idCard,
    phone,
    confirmPassword)
  return request({
    // url:'http://rq8sx5.natappfree.cc/user/register',
    url:'/api/user/register',
    method:'POST',
    // withCredentials: false,
    data:{
      username,
      password,
      sex,
      age:parseInt(age),
      idCard,
      phone,
      confirmPassword
    }
  })
}

// 登录
export const reqLogUser=(username,password)=>{
  return request({
    url:'/api/user/log',
    method:'POST',
    data:{
      username,
      password
    }
  })
}

// 获取用户信息
export const reqGetUserinfo=()=>{
  return request({
    url:'/api/user',
    method:'GET'
  })
}

// 修改密码
export const reqChangePassword=(oldPassword,newPassword)=>{
  const url=`/api/user/updatePassword`
  return request({
    url:url,
    method:'POST',
    data:{
      oldPassword,
      newPassword
    }
  })
}

// 获取验证码
export const reqGetCaptcha=(phone)=>{
  const url=`/api/user/sendCode/${phone}`
  return request({
    url:url,
    method:'GET'
  })
}

// 验证验证码
export const reqVerify=(code,phoneNumber)=>{
  return request({
    url:'/api/user/verifyCode',
    method:'GET',
    params:{
      code,
      phoneNumber
    }
  })
}

// 重置密码
export const reqResetPassword=(username,newPassword)=>{
  return request({
    url:'/api/user/reset',
    method:'POST',
    data:{
      username,
      newPassword
    }
  })
}

// 获取用户预约记录
export const reqGetReservation=()=>{
  return request({
    url:'/api/order/userOrder',
    method:'GET'
  })
}

// 预约记录支付
export const requserPay=(id)=>{
  return request({
    url:`/api/alipay/payNotPayOrder/${id}`,
    method:'GET'
  })
}